﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using HR60_PanelSoft.View.Base;
using HR60_PanelSoft.View.TabForms.ListItems;
using HR60_PanelSoft.Model;
using HR60_PanelSoft.Model.BaseModel;

namespace HR60_PanelSoft.View.TabForms
{
	public partial class PanelForm_ExPage : BaseForm
	{
		public PanelForm_ExPage()
		{
			InitializeComponent();
		}

		// 绑定数据
		public override void refreshFormData(System.Collections.Generic.IDictionary<string, object> dataMap)
		{
			HR60_PanelSoft.Model.Panel panel = (HR60_PanelSoft.Model.Panel) dataMap["panel"];
			
			// 遍历特殊设备
			panelMain.Controls.Clear();
			foreach (DeviceGroup group in deviceGroups)
			{
				foreach (Device device in group.devices)
				{
					if (device.type.exType != ExDeviceType.NULL)
					{
						// 显示分机列表
						SubExDeviceSelect ss = new SubExDeviceSelect();
						ss.bindExDevice(device);
						panelMain.Controls.Add(ss);

						// 初始化选项
						switch(device.type.exType)
						{
							case ExDeviceType.CentralAircon:
								ss.Value = panel.airconPage.mappingSubExDevice;
								break;
							case ExDeviceType.CentralHeating:
								ss.Value = panel.heatingPage.mappingSubExDevice;
								break;
							case ExDeviceType.CentralNewWind:
								ss.Value = panel.newWindPage.mappingSubExDevice;
								break;
							case ExDeviceType.BGM:
								ss.Value = panel.bgmPage.mappingSubExDevice;
								break;
						}
					}
				}
			}
		}

		// 数据修改事件
		public override void onFormChanged(BaseFormControl sender, System.EventArgs e)
		{
			
		}
	}
}
